﻿using System;
using System.Collections.Generic;
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Linq;
using Tong;
using JModel;

public partial class aspnet_testPargrameDir_site_Member_ChangePwd : System.Web.UI.Page
{
    public string str = "";
    /// <summary>
    /// 當前顯示的id
    /// </summary>
    string id = "1";

    /// <summary>
    /// 用於顯示資料
    /// </summary>
    public Tong.TongUse TextData = new Tong.TongUse();

    /// <summary>
    /// 系统安装绝对路径
    /// </summary>
    public string Abs_Path = TongUse.SysPath;
    /// <summary>
    /// 用户存放数据的临时表
    /// </summary>
    DataTable MyDt = new DataTable();

    public string ho = "";

    /// <summary>
    /// 站点通用方法类
    /// </summary>
    public Tong.ThisSiteUse.SiteTong TextThisSite = new Tong.ThisSiteUse.SiteTong();


    //得到传入的栏目ID
    public String CloumnID = "1";

    /// <summary>
    /// 顯示當前欄目的簡介
    /// </summary>
    public string str1 = "";
    /// <summary>
    /// 資料表
    /// </summary>
    DataTable NewDt = new DataTable();
    /// <summary>
    /// 用于分頁的對像
    /// </summary>
    Tong.Fy.FenYe FY = new Tong.Fy.FenYe();
    /// <summary>
    /// 
    /// </summary>
    public string sud = "";

    /// <summary>
    /// 標題
    /// </summary>
    public string title = "";
    /// <summary>
    /// 表名
    /// </summary>
    public string tab = "Sys_WangZhanDeTue3aae";
    /// <summary>
    /// 学生实体
    /// </summary>
    public CX_Student stud = null;

    JModel.DBEntities db = new JModel.DBEntities();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LoadData();

            DataBind();
        }
    }

    /// <summary>
    /// 帮定ID
    /// </summary>
    void DataBind()
    {

    }


    /// <summary>
    /// 内容状态保存时发生
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    public void Page_SaveStateComplete(object sender, EventArgs e)
    {

        db.Connection.Close();
        db.Dispose();
    }
    /// <summary>
    /// 加载数据
    /// </summary>
    CX_Student LoadData()
    {

        stud = null;
        if (Session["user"] != null)
        {
            stud = (CX_Student)Session["user"];
        }
        else
        {
            TextData.ResonseAlert("您长时间没有任何操作,请重新登录.");
            TextData.Res.Response.Write("<script>window.location.href='Login.aspx';</script>");
        }

        return stud;
    }

    /// <summary>
    /// 保存新密码
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSavePwd_Click(object sender, EventArgs e)
    {
        CX_Student stuentity=LoadData();
        if(stuentity !=null)
        {
            RegUser curuser = db.RegUser.Where(p => p.RegUser_LX == stuentity.学号).FirstOrDefault();
            if (curuser != null)
            {
                if (curuser.RegUser_CreatefileName == pwd.Text&&!string.IsNullOrEmpty(pwdnew.Text))
                {
                    curuser.RegUser_CreatefileName = pwdnew.Text.Trim();
                    db.SaveChanges();
                    TextData.ResonseAlert("保存密码成功");
                }
                else {
                    TextData.ResonseAlert("您输入的原始密码不正确,或者新密码为空");
                }
            }


    }}
}